<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.security.*;"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
</head>
<body>

<div align="right">
<a href="help/Manuale Amministratore.pdf" style="border:0px;" ><img src="img/help.png" style="border:0px;"></img></a>
</div>


<%
	
	boolean logout=request.getParameter("logout") == null ? false : true;
	if (logout){
		
		out.println("Logged out");
		
		if (session.getAttribute("username")!=null){
			
			session.setAttribute("username", null);
			
		}
	}
	
	
	if (session.getAttribute("username")!=null){
		String redirectURL = "admin.jsp";
		response.sendRedirect(redirectURL);
	}
	
	
	/*MessageDigest alg = MessageDigest.getInstance("MD5");
	alg.reset(); 
	alg.update("pepo_86".getBytes());
	byte[] digest = alg.digest();
	StringBuffer hashedpasswd = new StringBuffer();
	String hx;
	for (int i=0;i<digest.length;i++){
		hx =  Integer.toHexString(0xFF & digest[i]);
		if(hx.length() == 1){hx = "0" + hx;}
		hashedpasswd.append(hx);
	}
		out.println(hashedpasswd.toString());
	*/
%>
<div align="center">
<div align="center" style="margin-top:100px;width:316px;height:243px;no-repeat;background:url(img/login.png);">
	<form name="login" action="admin.jsp" method="post"><br /><br /><br /><br /><br /><br />
		
		<input type="hidden" name="show_auth_confirm" value="true">
				
		<label> Username: </label> <input type="text" name="user">
		<br />
		<label> Password: </label> <input type="password" name="pass">
		<br /><br />
	<input type="submit" value="Login"></input>
	</form>

</div>
</div>
</body>
</html>